import { ref } from "vue";
import {
  disabitity,
  education,
  persontype,
  undercontrol,
} from "./base_info_map";
import { menu_title } from "./title";
import { selectResPopInfo } from "@/api/resident_request";
import { select_idnum_info } from "../js/resident_request_func";
//常住人口
const target_household = ref({
  pid: "",
  pname: "",
  operatorId: "",
  name: "",
  idnum: "",
  birthday: "",
  genderId: "",
  nationId: "",
  bloodId: "",
  eduId: "",
  marryId: "",
  disabilityId: "",
  militaryId: "",
  address: "",
  popTypeId: "1",
  housenum: "",
  housetypeId: "",
  relationId: "",
  work: "",
  servicePlace: "",
  isDelete: "",
  operatorId: "",
  changetype: "",
  pid: "1",
  changereson: "",
});
const household = ref({
  pid: "",
  pname: "",
  operatorId: "",
  name: "",
  idnum: "",
  birthday: "",
  genderId: "",
  nationId: "",
  bloodId: "",
  eduId: "",
  marryId: "",
  disabilityId: "",
  militaryId: "",
  address: "",
  popTypeId: "1",
  housenum: "",
  housetypeId: "",
  relationId: "",
  work: "",
  servicePlace: "",
  isDelete: "",
  operatorId: "",
  changetype: "",
  pid: "1",
  changereson: "",
});
const flow = ref({
  name: "",
  idnum: "",
  pname: "",
  birthday: "",
  genderId: "",
  nationId: "",
  bloodId: "",
  eduId: "",
  marryId: "",
  disabilityId: "",
  militaryId: "",
  address: "",
  popTypeId: "3",
  livedate: "",
  livereason: "",
  liveaddress: "",
  operatorId: "1",
  changetype: "",
  pid: "1",
  changereson: "无",
  isDelete: "",
});
const important = ref({
  name: "",
  idnum: "",
  birthday: "",
  genderId: 1,
  nationId: "",
  bloodId: "",
  eduId: "",
  marryId: "",
  disabilityId: "",
  militaryId: "",
  address: "",
  popTypeId: "2",
  persontypeId: "",
  undercontrolId: "",
  personnum: "",
  operatorId: "1",
  changetype: "",
  pid: "1",
  changereson: "无",
  isDelete: "",
  pname: "",
});
const reset_params = (request_params) => {
  let keys = Object.keys(request_params);
  keys.forEach((key) => {
    request_params[key] = "";
  });
};
const search_info = async (index, path, idnum) => {
  if (index != 0) {
    switch (menu_title.value[path][0]) {
      case "1":
        select_idnum_info(idnum, path);
        break;
      case "2":
        reset_params(important.value);
        break;
      case "3":
        reset_params(flow.value);
        break;
    }
  }
};
export {
  target_household,
  household,
  flow,
  important,
  search_info,
  reset_params,
};
